#include <REGX52.H>
#include "LCD1602.h"
#include "TIMER0.h"

int hour=11;
int minute=57;
int second=00;
	
int main()
{

	Timer0_Init();
	LCD_Init();
	LCD_ShowString(1,1,"Clock:");
	LCD_ShowString(2,1,"  :  :");
	while(1)
	{
		LCD_ShowNum(2,1,hour,2);
		LCD_ShowNum(2,4,minute,2);
		LCD_ShowNum(2,7,second,2);
	}
	
	return 0;
}

void Timer0_routine() interrupt 1
{
//	static int hour=11;
//	static int minute=57;
//	static int second=00;
	static int countnum=0;
	countnum++;
	TH0=0xfc;//1111 1100
	TL0=0x18;//0001 1000
	if(countnum==1000)
	{
		countnum=0;
		second++;
		if(second==60)
		{
			second=0;
			minute++;
		}
		if(minute==60)
		{
			minute=0;
			hour++; 
		}
		if(hour==24)
		{
			hour=0;
		}
//		LCD_ShowNum(2,1,hour,2);
//		LCD_ShowNum(2,4,minute,2);
//		LCD_ShowNum(2,7,second,2);
	}
}
